
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("fnId", request.getAttribute("fnId"));
	pageContext.setAttribute("userPwoer", request.getSession().getAttribute("userPwoer"));
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body class="gray-bg">
	<nav class="huiNav">
		<i class="fa fa-home"></i> 首页 <span>&gt;</span>房源管理<span>&gt;</span>房源信息
		<a class="btn btn-info  btn-sm pull-right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="fa fa-refresh"></i></a>
	</nav>

	<div class="ibox-content">
		<!-- 搜索框部分start -->
		<p:btn value="serch">
			<form class="form-inline" id="serchform">

				<label for="exampleInputName2">房源类型</label>
				<div class="form-group mr-20">
					<div class="col-sm-4 ">
						<select class="form-control autoFull " name="fyKinds"
							data-filed="name" data-value="name"
							data-url="${path}/admin/dataDictionary/showDataDictionary"
							data-param="{type:'房源类型'}">
							<option value=''>--请选择房源类型--</option>
						</select>
					</div>
				</div>
				<label for="exampleInputName2">供求</label>
				<div class="form-group mr-20">
					<div class="col-sm-4 ">
						<select class="form-control autoFull " name="fyGq"
							data-filed="name" data-value="name"
							data-url="${path}/admin/dataDictionary/showDataDictionary"
							data-param="{type:'供求'}">
							<option value=''>--请选择供求类型--</option>
						</select>
					</div>
				</div>
				<label for="exampleInputName2">房源来源</label>
				<div class="form-group mr-20">
					<div class="col-sm-4 ">
						<select class="form-control autoFull " name="fySource"
							data-filed="name" data-value="name"
							data-url="${path}/admin/dataDictionary/showDataDictionary"
							data-param="{type:'房源来源'}">
							<option value=''>--请选择房源来源--</option>
						</select>
					</div>
				</div>
				<label for="exampleInputName2">审核状态</label>
				<div class="form-group mr-20">
					<div class="col-sm-4 ">
						<select class="form-control autoFull " name="glCheckStatus"
							data-filed="name" data-value="name" 
							data-url="${path}/admin/dataDictionary/showDataDictionary"
							data-param="{type:'审核状态'}">
							<option value=''>--请选择审核状态--</option>
						</select>
					</div>
				</div>
				<label for="exampleInputName2">发布状态</label>
				<div class="form-group mr-20">
					<div class="col-sm-4 ">
						<select class="form-control autoFull " name="glPublishStatus"
							data-filed="name" data-value="name" 
							data-url="${path}/admin/dataDictionary/showDataDictionary"
							data-param="{type:'发布状态'}">
							<option value=''>--请选择发布状态--</option>
						</select>
					</div>
				</div>
				<label for="exampleInputName2">置顶</label>
				<div class="form-group mr-20">
					<div class="col-sm-4 ">
						<select class="form-control  " name="glIsTop" style="width: 100px;">
							<option value=''>--置顶状态--</option>
							<option value='是'>是</option>
							<option value='否'>否</option>
						</select>
					</div>
				</div>
				<label for="exampleInputName2">有效状态</label>
				<div class="form-group mr-20">
					<div class="col-sm-4 ">
						<select class="form-control  " name="yxzt" style="width: 100px;">
							<option value='有效'>有效</option>
							<option value='失效'>失效</option>
						</select>
					</div>
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">标题</label> <input name="fyTitle"
						type="text" class="form-control">
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">联系人</label> <input name="fyLxr"
						type="text" class="form-control">
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">发布时间</label> <input name="beginTimeQuery"
						id="beginTime" type="text" class="form-control datetimepicker">—
					<input name="endTimeQuery" id="endTime" type="text"
						class="form-control datetimepicker">
				</div>
				<button onclick="myGrid.serchData()" type="button"
					class="btn btn-info btn-sm">
					<i class="fa fa-search "></i> 搜索
				</button>
				<button type="reset" class="btn btn-info btn-sm">
					<i class="fa fa-refresh "></i> 重置
				</button>
			</form>
		</p:btn>
		<!-- 搜索框部分en -->
		<div class="option-bar">
			<p:btn value="dels">
				<button onclick="myGrid.delItems()" type="button"
					class="btn btn-danger btn-sm">
					<i class="fa fa-trash"></i>批量删除
				</button>
			</p:btn>
			<p:btn value="add">
				<button onclick="openAdd()" type="button"
					class="btn btn-success btn-sm">
					<i class="fa fa-plus"></i> 新增
				</button>
			</p:btn>
		</div>
		<table id="mgrid">
			<thead>
				<tr>
					<th data-checkbox="true"></th>
					<th data-formatter="MGrid.indexfn" data-align="center"
						data-width="30px">序号</th>
					<th data-field="fyTitle">标题</th>
					<th data-field="fyKinds">房屋类型</th>
					<th data-field="fyGq">供求</th>
					<th data-field="fyLxr">联系人</th>
					<th data-field="fyLxdh">联系电话</th>
					<th data-field="glCreateTime" data-formatter="MGrid.getTime">创建时间</th>
					<th data-field="glIsTop"  data-formatter="buidIntop">置顶</th>
					<th data-field="fySource">房源来源</th>
					<th data-field="user.name">发布人</th>
					<th data-field="glCheckStatus" data-formatter="buidCheck" >审核状态</th>
					<th data-field="glPublishStatus">发布状态</th>
					<th data-align="center" data-width="150px" data-field="id"
						data-formatter="buidOperate">操作</th>
				</tr>
			</thead>
		</table>
	</div>

	<script type="text/javascript">
		var myGrid;
		$(function() {
			var delUrl = "";
			<p:btn value="dels">
			delUrl = "${path}/admin/fy/del";
			</p:btn>
			myGrid = MGrid.initGrid({
				url : "${path}/admin/fy/showList",
				delUrl : delUrl
			});

			MTools.autoFullSelect();
			MTools.ininDatetimepicker({
				format : "yyyy-mm-dd hh:ii",
				minView: "hour"
			});
			MTools.limitStartEndTime();

		});

		function buidOperate(value, row, index) {
			var html = '';
			<p:btn value="check">
			if(row.glCheckStatus=='待审核'){
			html += '<button class="btn btn-default btn-sm mr-5" onClick="openEdit('+value+',2)"  title="审核"><i class="fa fa-gavel"></i></buttoun>'
			}
			</p:btn>
			<p:btn value="edit">
			html += '<button class="btn btn-default btn-sm mr-5" onClick="openEdit('+ value+ ',1)"  title="编辑"><i class="fa fa-edit"></i></buttoun>'
			</p:btn>
			<p:btn value="del">
			html += '<button class="btn btn-default btn-sm mr-5" onClick="myGrid.delItem('
					+ value
					+ ')" title="删除"><i class="fa fa-lg fa-trash-o"></i></buttoun>';
			</p:btn>
			return html;
		}
		function buidCheck(value, row, index) {
			if(value=='待审核'){
				return "<span class='label label-warning' >"+value+"</span>";
			}else if(value=="审核通过"){
				return "<span class='label label-success' >"+value+"</span>";
			}else if(value=="审核未通过"){
				return "<span class='label' >"+value+"</span>";
			}
		
		}
		function buidIntop(value, row, index) {
			if(value=='是'){
				return "<img src='${path}/resource/images/d.png' />";
			}else if(value=="否"){
				return "否";
			}
		
		}
		//打开添加界面
		<p:btn value="add">
		function openAdd() {
			layer.full(layer.open({
				type : 2,
				title : "添加房源",
				area : [ MUI.SIZE_L, '400px' ],
				content : [ '${path}/admin/fy/addForm' ]
			}));
		}
		</p:btn>
		//打开编辑界面
		<p:btn value="edit">
		function openEdit(id,flag) {
			layer.full(layer.open({
				type : 2,
				title : "编辑房源",
				area : [ MUI.SIZE_L, '400px' ],
				maxmin : true,
				content : [ '${path}/admin/fy/editForm?flag='+flag+'&id=' + id ]
			}));
		}
		</p:btn>

		//重置密码
		<p:btn value="resetPass">
		function resetPass(id) {
			layer.msg('重置后密码为【123】确定重置密码吗？', {
				time : 0,
				icon : 3,
				btn : [ '确定', '取消' ],
				yes : function(index) {
					layer.close(index);
					//*把密码设置为123
					$.AjaxProxy({
						a : false,
						c : false,
						p : {
							id : id
						}
					}).invoke("${path}/admin/fy/resetPassword", function(loj) {
						if (loj.attr("result").status == 'ok') {
							layer.msg("密码重置成功", {
								icon : 1
							});
						}
					});

				}
			});

		}
		</p:btn>
	</script>
</body>
</html>
